from google.appengine.ext import db

class Event(db.Model):
    TITLE = db.StringProperty(required=True)
    ORGANIZER = db.StringProperty
    LOCATION = db.StringProperty(required=True)
    GEOPT = db.GeoPtProperty
    FROM = db.DateProperty(required=True)
    HASHTAG = db.StringProperty
    URL = db.LinkProperty(required=True)
    TAGS = db.ListProperty(str)


from google.appengine.ext import db
from google.appengine.tools import bulkloader
import datetime 


class EventLoader(bulkloader.Loader):
  def __init__(self):
    bulkloader.Loader.__init__(self, 'Event',
                                     [('TITLE', lambda x:x.decode('utf-8')),
                                      ('ORGANIZER', lambda x:x.decode('utf-8')),
                                      ('LOCATION', lambda x:x.decode('utf-8')),
                                      ('GEOPT', db.GeoPt), 
    				      ('FROM', lambda x: datetime.datetime.strptime(x,'%d.%m.%Y %H:%M').date()),
				      ('HASHTAG', lambda x:x.decode('utf-8')),    				      
				      ('URL', str),
    				      ('TAGS', lambda x: [str(v) for v in x.split(":")]),
                                     ])

loaders = [EventLoader]
